package top.zhangjianyong.tools.service.mybatis.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import top.zhangjianyong.tools.entity.UserWatched;
import top.zhangjianyong.tools.mapper.UserWatchedMapper;
import top.zhangjianyong.tools.service.mybatis.IUserWatchedService;

import java.util.List;

/**
 * @author ： zhangjianyong
 * @date ： 2023/3/9 8:57 AM
 */
@Service
public class IUserWatchedServiceImpl extends ServiceImpl<UserWatchedMapper, UserWatched> implements IUserWatchedService {

    @Override
    public boolean del(Long userId, Long videoId) {
        return lambdaUpdate().eq(UserWatched::getUserId, userId)
                .eq(UserWatched::getVideoId, videoId)
                .set(UserWatched::getDelFlag, 1)
                .update();
    }

    @Override
    public List<UserWatched> list(Long userId) {
        return lambdaQuery().eq(UserWatched::getUserId, userId).list();
    }
}
